package com.atguigu.yygh.order.config;

import com.atguigu.yygh.mq.MqConst;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * ClassName: OrderConfig
 * Package: com.atguigu.yygh.order.config
 * Description:
 *
 * @Author: cqk
 * @Create: 2023/10/6 - 11:36
 * @Version: v1.0
 */
//@SpringBootConfiguration
public class OrderConfig {
    @Bean
    public Exchange getExchange(){
        return ExchangeBuilder.directExchange(MqConst.EXCHANGE_DIRECT_ORDER).durable(true).build();
    }

    @Bean
    public Queue getQueue(){
        return QueueBuilder.durable(MqConst.QUEUE_ORDER).build();
    }

    @Bean
    public Binding getBinding(@Qualifier("getExchange") Exchange exchange, @Qualifier("getQueue") Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with(MqConst.ROUTING_ORDER).noargs();
    }

}
